<?php
class AdminsController extends AppController {
    public $layout = 'default';
    public function beforeFilter() {
        $this->Auth->deny();
    }
    public function isAuthorized($user) {
        $this->loadModel('User');
        $this->User->id = $user['id'];
        $this->User->unbindModel(array('hasMany' => array('Test')));
        $role = $this->User->read('role');
        if($role['User']['role'] == 'none') {
            return false;
        }
        if($role['User']['role'] == 'admin') {
            return true;
        }
    }
    
    public function index() {
        
    }
    public function users() {
        $this->set('title', 'Danh sách người dùng :: ChomoTech');
        $this->loadModel('User');
        $this->User->unbindModel(array('hasMany' => array('Test')));
        $this->paginate = array(
            'Test' => array(
                'limit' => 20,
                'order' => array('created' => 'desc')
            )
        );
        $this->set('usersView', $this->paginate('User'));
    }
    public function user($action, $id) {
        switch($action) {
            case 'view':
                $this->set('title', 'Xóa Đề :: ChomoTech');
                $this->loadModel();
                break;
        }
    }
}
?>